关于执行scanf("%2d%f",&a,&b);的C语言题目

来源:百度知道 编辑:UC知道 时间:2024/05/21 20:46:34
设有定义: int a; float b; 执行scanf("%2d%f",&a,&b);语句时,若从键盘输入876543.0<CR>,
b的值为什么是6.000000而不是6543.000000呢?

#include<stdio.h>

void main()
{
int a; float b;
scanf("%2d%f",&a,&b);
printf("%d %f",a,b);
}
VC6.0下的执行结果:
654321
65 4321.000000Press any key to continue

对于输入的两个数之间应该有空格或回车。

b的值是6543.000000 而不是6.000000